home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / klipdial.zip / DIALIT87.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  7KB  |  260 lines

  1. ;
  2. ;               ╔════════════════════════════════════════╗
  3. ;               ║                                        ║
  4. ;               ║      This program is adapted from      ║
  5. ;               ║                                        ║
  6. ;               ║               DTR and AT               ║
  7. ;               ║                   by                   ║
  8. ;               ║     Donavon Kuhn  &  Jon Niedfeldt     ║
  9. ;               ║                (c) 1985                ║
  10. ;               ║                                        ║
  11. ;               ║       Adaptation for Clipper (S87)     ║
  12. ;               ║                   by                   ║
  13. ;               ║               John Karns               ║
  14. ;               ║                                        ║
  15. ;               ║        Clipper/Modem Interface         ║
  16. ;               ║                                        ║
  17. ;               ║              CLIPDIAL.ASM              ║
  18. ;               ║                                        ║
  19. ;               ║             v1.0  10/25/88             ║
  20. ;               ║                                        ║
  21. ;               ╚════════════════════════════════════════╝
  22. ;
  23. ;
  24. ;   Thank you Mssrs. Kuhn and Niedfeldt!
  25. ;
  26. ;   Calling syntax:  Call DIALIT with "Hayes command"
  27. ;                    where the hayes command is a character string
  28. ;                    without the AT on the front.  (Since all commands
  29. ;                    start with an AT, the module will supply it).
  30. ;
  31. ;                    COM1 is the default unless you specify otherwise.
  32. ;
  33. ;   Examples:
  34. ;            Call DIALIT with "Com2:DT1234567"  && Can use COM1 thru 4
  35. ;
  36. ;            Call DIALIT with "DT1234567" && Dial # 1234567 (default COM1)
  37. ;
  38. ;            Call DIALIT with "H"         && Hang up
  39. ;
  40. ;            (Upper or lower case may be used.)
  41. ;
  42.  
  43.  
  44.  
  45. upcase  macro   char
  46.     local    nocvt
  47.  
  48.     ifb    <char>
  49.  
  50.     upcase    al
  51.  
  52.     else
  53.  
  54.     cmp    char,'a'
  55.     jb    nocvt
  56.     cmp    char,'z'
  57.     ja    nocvt
  58.     sub    char,32
  59. nocvt:
  60.     endif
  61.     endm
  62.  
  63.  
  64.     PUBLIC  DIALIT
  65.  
  66.  
  67. extrn     __PARC:far      ; Clipper's character 'getter'
  68. extrn     __RETNI:far     ; Clipper's (Short) Integer 'returner'
  69.  
  70. ;-------------------------- stack area begins --------------------+
  71. stacks    segment   stack     ; stack segment starts here
  72.       dw        10 dup(0)  ; reserve 5 levels of stack with zeros
  73. stacks    ends                ; stack segment ends
  74.  
  75. ;-------------------------- data area begins ---------------------+
  76. ;
  77. DGROUP  GROUP   datasg  ; Clipper's Data Segment
  78.  
  79. ;               the 'public' in the next statement combines
  80. ;               the datasg to Clipper's DGROUP group
  81.  
  82. datasg    segment public  'DATA'
  83.  
  84. OFFVAL    dw      0             ; init with 0
  85. SEGVAL    dw      0             ; init with 0
  86.  
  87. datasg    ends                     ; end of datasg (in DGROUP)
  88.  
  89. ;-------------------------- code area starts ---------------------+
  90.  
  91. _prog   segment BYTE  'CODE'
  92.     assume  cs:_prog,ds:datasg,ss:stacks
  93.  
  94.  
  95. DIALIT          proc    far
  96.  
  97.         push    bp              ; preserve return address
  98.     mov     bp,sp           ; move stack pointer
  99.     push    ds
  100.     push    es
  101.     push    si
  102.     push    di
  103.  
  104.         mov     ax,1            ; get first para
  105.         push    ax              ; push AX
  106.         call    __PARC          ; call Chara "getter"
  107.         add     sp,2            ; restore stack
  108.     mov     OFFVAL,ax       ; get OFFSET address
  109.     mov     SEGVAL,dx       ; get SEGMENT address
  110.  
  111.     mov     ax,DGROUP       ; get DGROUP segment
  112.     mov     es,ax           ; and place in ES
  113.  
  114. ; in the next three statements, the order that it appears is
  115. ; important because the values of SI & AX must first be taken
  116. ; from the DATASG extension before assigning the DGROUP segment
  117. ; address to DS
  118.  
  119.     mov     si,OFFVAL
  120.     mov     ax,SEGVAL
  121.     mov     ds,ax
  122.     xor     ax,ax           ; zero out AX
  123.     mov     al,[si]         ; move first SI value to AL
  124.  
  125.  
  126. ;--------------------- Start "AT" routine -----------------------+
  127.     jmp     start1
  128.  
  129. base    dw    0
  130.  
  131. start1:
  132.     mov     bl,0                    ;default com port (COM1:)
  133.  
  134.     upcase                          ;using UPCASE without a parameter
  135.     cmp     al,'C'                  ;(defaults to AL)
  136.     jnz     nocom
  137.  
  138.     mov     cl,[si][1]
  139.     upcase  cl                      ;using UPCASE using another register
  140.     cmp     cl,'O'
  141.     jnz     nocom
  142.  
  143.     mov     al,[si][2]
  144.     upcase  al                      ;using UPCASE with AL as the parm
  145.     cmp     al,'M'
  146.     jnz     nocom
  147.  
  148.     cmp     byte ptr [si][4],':'
  149.     jz      check_port
  150.  
  151. toohi:
  152.     mov    bx,1
  153.     jmp     alldone
  154. notfound:
  155.     mov    bx,2
  156.     jmp     alldone
  157.  
  158. check_port:
  159.     mov    al,[si][3]        ; get the com number
  160.     sub    al,'1'            ; convert to binary
  161.     cmp    al,3            ; greater than com4?
  162.     ja    toohi                   ; error code 1
  163.     add     si,5                    ; set string pointer after colon
  164.     mov     bl,al                   ; move the port # to bl
  165.  
  166. nocom:
  167.     xor     bh,bh
  168.     shl    bl,1
  169.     mov     ax,40h
  170.     push    ds                      ; preserve ds
  171.     mov     ds,ax
  172.     mov    ax,ds:[bx]
  173.     pop     ds                      ; restore ds
  174.     cmp    ax,0
  175.     jnz    comok
  176.  
  177.     jmp    notfound
  178.  
  179. comok:
  180.     push    ax
  181.     call    dtr_on
  182.     pop    ax
  183.     mov     base,ax
  184.     mov    al,'A'
  185.     call    auxout
  186.     mov    al,'T'
  187.     call    auxout
  188.  
  189. outlp:
  190.     mov     al,[si]
  191.     inc     si
  192.     call    crtest
  193.     call    auxout
  194.     cmp     al,13                   ; originally, a CHR(13) had to appended
  195.     jnz     outlp
  196.  
  197.     xor    bx,bx            ; error code 0 - no errors
  198.     jmp     alldone
  199.  
  200.  
  201. crtest  proc    near
  202.     cmp     al,0                    ; chek 4 null terminator
  203.     jne     notnull                 ; no, next char
  204.     mov     al,13                   ; yes, add CR
  205. notnull: ret
  206. crtest  endp
  207.  
  208.  
  209. dtr_on  proc    near
  210.     mov     dx,ax
  211.     add    dx,4
  212.     in    al,dx
  213.     or      al,3                    ;set dtr bit
  214.     out     dx,al
  215.     ret
  216. dtr_on  endp
  217.  
  218.  
  219. auxout  proc    near
  220.     push    ax
  221.     mov    dx,base
  222.     add    dx,5
  223.  
  224. txlp:
  225.     in    al,dx
  226.     and    al,20h
  227.     jz    txlp
  228.  
  229.     pop    ax
  230.     sub    dx,5
  231.     out    dx,al
  232.     ret
  233. auxout    endp
  234.  
  235.  
  236. ;-------------------------- code area ends ---------------------+
  237.  
  238. alldone:
  239.  
  240.     pop     di              ; restore registers
  241.     pop     si
  242.     pop     es
  243.     pop     ds
  244.     pop     bp
  245.  
  246.     mov     ax,DGROUP       ; get DGROUP address
  247.     mov     ds,ax           ; assign to DS
  248.     push    ds              ; push segment address
  249.  
  250.     push    bx        ; error code
  251.     call    __RETNI        ; pass to Clipper
  252.     pop    bx        ; restore stack
  253.     pop     ds              ; restore
  254.     ret                     ; actual ret to caller
  255. dialit  endp
  256.  
  257. _prog   ends                    ; end of segment
  258.     end
  259.  
  260.